<template>
  <layout>
    <keep-alive>
      <router-view v-if="$route.meta.keepAlive"></router-view>
    </keep-alive>
    <router-view v-if="!$route.meta.keepAlive"></router-view>
  </layout>
</template>

<script>
import Layout from "@/components/Layout.vue";
import { getWalletList, getParaList, getMainChains } from "./common.service";
export default {
  name: "App",
  components: {
    layout: Layout,
  },
  mounted() {
    this.getWallets();
    this.getChain();
    if (process.env.VUE_APP_TOKENMANAGE === "true") this.getParallels();
  },
  methods: {
    async getWallets() {
      const res = await getWalletList();
      if (res && res.code === 0) {
        this.$store.commit("updateWallets", res.data);
      } else {
        this.$store.commit("updateWallets", []);
      }
    },
    async getParallels() {
      const res = await getParaList();
      if (res && res.code === 0) {
        this.$store.commit("updataParallel", res.data.items);
      } else {
        this.$store.commit("updataParallel", []);
      }
    },
    async getChain() {
      const res = await getMainChains();
      if (res && res.code === 0) {
        this.$store.commit("updateMainChains", res.data.items);
      } else {
        this.$store.commit("updateMainChains", []);
      }
    },
  },
};
</script>

<style lang="scss">
</style>
